<template>
  <div>
    <home-book
      :row="category.length / 2"
      :col="2"
      :data="category"
      mode="category"
      @onBookClick="(item)=>onCategoryClick(item)"
    ></home-book>
  </div>
</template>

<script>
  import HomeBook from '../../components/home/HomeBook.vue';
  import {getAllCategory} from '../../api';
  export default {
    name: "index",
    components : {
      HomeBook,
    },
    mounted(){
      this.getAllCategory();
    },
    data(){
      return {
        category : [],
      }
    },
    methods : {
      getAllCategory(){
        getAllCategory().then(response=>{
          this.category = response.data.data;
        });
      },
      onCategoryClick(item){
        let category = item.categoryText;
        this.$router.push({
          path : '/pages/list/main',
          query : {
            category,
          }
        });
      },
    },
  };
</script>

<style scoped>

</style>
